<template>
	<view class="fan">
		<template v-for="(item,index) in fanList">
			<view class="flex alignCenter one" :key="index" @click="toHomePage(item)">
				<image :src="item.createUserAvatar || 'https://image.alhelp.net/uploads/20231104/4d491857ac50d21ebbcb25ff5bc254f8.png'" mode=""></image>
				<view class="hiddenOneline font14">{{item.createUserName || '匿名用户'}}</view>
			</view>
		</template>
		<uni-nodata v-if="fanList.length==0" :iconStyle="{'margin':'100rpx 0 0'}"></uni-nodata>
	</view>
</template>

<script>
	import { focusFanList } from "@/api/mine.js"
	export default {
		data() {
			return {
				// fanList:[{
				// 	status:0,
				// 	nickName:'黑粉1',
				// 	avatar:'https://web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
				// },{
				// 	status:1,
				// 	nickName:'黑粉2',
				// 	avatar:'https://web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
				// },{
				// 	status:2,
				// 	nickName:'黑粉3',
				// 	avatar:'https://web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png'
				// }],
				fanList:[],
				userId:'',
				page:1,
				pageSize:20,
				pageTotal:0,
			};
		},
		onLoad(option) {
			this.userId=option.userId?option.userId:uni.getStorageSync('userId')
			this.getList()
		},
		methods:{
			initPage(){
				this.page=1;
				this.fanList=[]
			},
			getList(){
				let param={
					page:this.page,
					size:this.pageSize,
					userId:this.userId,
					isFollowersView:false
				}
				focusFanList(param).then((res)=>{
					if(res.code==100000){
						this.fanList=this.fanList.concat(res.data.rows)
						this.pageTotal=Math.ceil(res.data.total/this.pageSize)
					}
				})
			},
			focusBack(item){
				item.status=(item.status==0?1:0)
			},
			// 去主页
			toHomePage(item){
				console.log('主页===',item)
				uni.navigateTo({
					url:'/pages/mine/homePage/homePage?userId='+item.createUserId
				})
			}
		},
		onPullDownRefresh() {
			this.initPage()
			this.getList()
			setTimeout(()=>{
				uni.stopPullDownRefresh()
			},1000)
		},
		onReachBottom() {
			if(this.page<this.pageTotal){
				++this.page
				this.getList()
			}else{
				uni.showToast({
					title:'我也是有底线的',
					icon:'none'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
::v-deep .uni-list-chat__content{
	align-items: center;
}
::v-deep .uni-list-chat__content-title{
	font-size: 32rpx;
}
::v-deep .uni-list-chat__header-image{
	margin:0;
}
.fan{
	padding: 0 30rpx;
	box-sizing: border-box;
}
.one{
	border-bottom:1px solid $bordercolor;
	padding: 30rpx 0;
	image{
		width:90rpx;
		height:90rpx;
		border-radius: 50%;
		margin-right: 20rpx;
		flex-shrink: 0;
	}
	&>view{
		flex:1
	}
}

</style>
